//
//  CodeTextFieldView.m
//  AiShangJinFuSalesman
//
//  Created by AiShangTong on 2017/6/6.
//  Copyright © 2018年 AiShangTong. All rights reserved.
//

#import "CodeTextFieldView.h"

@interface CodeTextFieldView ()

@property (nonatomic, strong) UIImageView *lineImageView;

@end

@implementation CodeTextFieldView

- (instancetype)init {
    
    self = [super init];
    if (self) {
        
        [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(self.mas_left);
            make.right.mas_equalTo(self.mas_right);
            make.height.mas_equalTo(0.5f);
            make.bottom.mas_equalTo(self.mas_bottom);
        }];

        
        [self.codeButton mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.bottom.mas_equalTo(self.mas_bottom);
            make.height.mas_equalTo(50);
            make.right.mas_equalTo(self.mas_right);
            make.width.mas_equalTo(90);
        }];
        
        [self.writeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.mas_equalTo(self.mas_left);
            make.right.mas_equalTo(self.codeButton.mas_left).offset(-8);
            make.bottom.mas_equalTo(self.mas_bottom);
            make.height.mas_equalTo(50);
        }];
        
        [self bringSubviewToFront:self.lineImageView];
    }
    return self;
}



- (MSQTextField *)writeTextField {
    
    if (!_writeTextField) {
        _writeTextField = [[MSQTextField alloc] init];
        [_writeTextField setLeftViewMode:UITextFieldViewModeAlways];
        [self addSubview:_writeTextField];
    }
    return _writeTextField;
}

- (CodeButton *)codeButton {
    
    if (!_codeButton) {
        _codeButton = [[CodeButton alloc]initWithFrame:CGRectZero];
        
        _codeButton.titleLabel.font = [UIFont systemFontOfSize:14];
        
        [self addSubview:_codeButton];
    }
    return _codeButton;
}



- (UIImageView *)lineImageView {
    
    if (!_lineImageView) {
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.backgroundColor = ThemeMaoLineColor;
        _lineImageView.layer.cornerRadius = 0.25f;
        _lineImageView.layer.masksToBounds = YES;
        [self addSubview:_lineImageView];
    }
    return _lineImageView;
}










@end
